 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package objects;
import OBJ_Loader.Object;
import graphic.Graphic;
import org.lwjgl.util.vector.Vector3f;
/**
 *
 * @author Marcin
 */
public class Mill {
    public Object Main;
    public Object Vane;
    
    public SRect rect = new SRect();
    
    public float size=4f;
    public float speed=1f;
    public float mSize=10.4f;
    public float scale=1f;
    public Vector3f coord=new Vector3f(0,0,0);
    
    public void move(float x,float y, float z){
        coord.x=x;
        coord.y=y;
        coord.z=z;
        Main.move(x, y, z);
        Vane.move(x, y+mSize*scale, z);
    }
    public void setRot(float rot){
        Main.setRotateY(rot);
        Vane.setRotateY(rot);
    }
    public Mill(float x,float y , float z, float scale){
        coord.x=x;
        coord.y=y;
        coord.z=z;
        this.scale=scale;
        size*=scale;
        rect.set(x-size, x+size, z-size, z+size);
       Main = new Object("obj/nMlyn.obj",x,y,z);
       Vane = new Object("obj/nSmigla.obj",x,y+mSize*scale,z,0,-mSize,0);
       Main.setScale(scale);
       Vane.setScale(scale);
    }
    public SRect getRect(){
        return rect;
    }
    public void draw(){
        Main.draw();
        manualDraw();
        Vane.setRotateX(10);
        Vane.addRotateZ(speed);
    }
    public void manualDraw(){
        Graphic.e.push();
        Graphic.e.translate(Vane.getPos());
        if(Vane.getRot().y!=0) Graphic.e.rotY(Vane.getRot().y);
        if(Vane.getRot().x!=0) Graphic.e.rotX(-Vane.getRot().x);
        if(Vane.getRot().z!=0) Graphic.e.rotZ(Vane.getRot().z);
        if(Vane.getRot().x!=0) Graphic.e.rotX(Vane.getRot().x);
        Graphic.e.scale(Vane.getScale());
        Graphic.e.drawList(Vane.getM().getID());
        Graphic.e.pop();        
    }
}
